﻿namespace Luka;

/// <summary>
/// 数据规则(常用的正则表达式)
/// </summary>
[NotScanned]
public partial class RulePattern
{
    /// <summary>
    /// 邮箱
    /// </summary>
    public const string Email = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";

    /// <summary>
    /// QQ号
    /// </summary>
    public const string QQ = @"^[1-9]\d{4,}$";

    /// <summary>
    /// 身份证号
    /// </summary>
    public const string IDNum = @"^\d{17}[\d|X|x]$";

    /// <summary>
    /// 日期格式（YYYY-MM-DD）
    /// </summary>
    public const string Date = @"^\d{4}-\d{2}-\d{2}$";

    /// <summary>
    /// Url
    /// </summary>
    public const string Url = @"^(https?|ftp)://[^\s/$.?#].[^\s]*$";

    /// <summary>
    /// IPv4
    /// </summary>
    public const string IPv4 = @"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";

    /// <summary>
    /// 手机号
    /// </summary>
    public const string Phone = @"^1[3-9]\d{9}$";

    /// <summary>
    /// 数字
    /// </summary>
    public const string Number = @"^[0-9]*$";

    /// <summary>
    /// 邮政编码
    /// </summary>
    public const string PostalCode = @"^\d{6}$";

    /// <summary>
    /// 金额
    /// </summary>
    public const string Money = @"^-?\d{1,3}(?:,?\d{3})*\.\d{2}$";

    /// <summary>
    /// 最少8位密码
    /// </summary>
    public const string Password = @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$";

    /// <summary>
    /// 用户名（只允许包含中文、英文、数字和下划线）
    /// </summary>
    public const string Name = @"^[\u4e00-\u9fa5a-zA-Z0-9_]+$";

    /// <summary>
    /// 只允许中文
    /// </summary>
    public const string Chinese = @"^[\u4e00-\u9fa5]+$";

    /// <summary>
    /// 只允许英文
    /// </summary>
    public const string English = @"^[a-zA-Z]+$";
}